<%--
  Created by IntelliJ IDEA.
  User: fyf
  Date: 2018/11/12
  Time: 9:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>添加教师信息</title>

  <jsp:include page="/common/basecss.jsp" flush="true"/>
  <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.js"></script>
  <script src="${pageContext.request.contextPath}/assets/js/layer-v3.1.0/layer/layer.js"></script>
</head>
<body>


<form id="teacherForm" class="form-inline" method="post">

  <h5 class="page-header alert-info" style="padding:10px; margin:0px; margin-bottom:5px;">教师信息</h5>
  <div class="row">

    <div class="form-group">
      <label class="col-sm-3 control-label">教师id</label>
      <div class="col-sm-6">
        <input type="text" name="id" readonly="readonly" class="form-control input-sm"
               placeholder="教师id由数据库后台生成" />
      </div>
    </div>

  </div>

  <div class="row">

    <div class="form-group">
      <label class="col-sm-3 control-label">教师姓名</label>
      <div class="col-sm-6">
        <input type="text" name="teachername" id="teachername"  class="form-control input-sm"
               placeholder="请填写教师姓名"    required/>
      </div>
    </div>

  </div>

  <%--分公司id--%>
  <input type="hidden" name="branchid" id="branchid"   value="${branchid}">

  <div class="row">
    <div class="text-center">
      <input  type="button" id="submitButton" class="btn btn-success" value="添加"/>

    </div>
  </div>
</form>

<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery2.1.4.js"></script>
<script src="assets/js/layer-v3.1.0/layer/layer.js"></script>

<script src="assets/jquery-validation-1.14.0/lib/jquery.js"></script>
<script src="assets/jquery-validation-1.14.0/dist/jquery.validate.js"></script>
<script src="assets/jquery-validation-1.14.0/dist/localization/messages_zh.js"></script>
<script type="text/javascript">

    $(function () {

        $("#submitButton").click(function () {

            var teachername = $('#teachername').val();
            var branchId= $('#branchid').val();
            $.ajax({
                type:'post',
                url:'addTeacher.go',
                data:{"teachername":teachername,"branchId":branchId},
                dataType:'json',
                success:function (resData) {
                    if (resData!=null&&resData.teachername!=""&&resData.teachername!=null){
                        layer.msg('教师添加成功',{icon: 1});
                        /*ajax提交，成功之后父级页面刷新*/
                        setTimeout(function () {
                            parent.location.reload();
                        },1000);

                    }else if(resData.teachername=null||resData.teachername==""){
                        layer.msg('请填写教师名称',{icon: 4});
                    }else {
                        layer.msg('教师添加失败',{icon: 2});
                    }
                },
                error:function () {

                }
            });
        });




    });


</script>




<jsp:include page="/common/basejs.jsp" flush="true"/>
</body>
</html>
